﻿using System.Data;
using System;
using System.Collections.Generic;
namespace E2_WEBSITE.Code.Admin
{
    public class AdsController
    {
        AdsDataAccess m_DataAccess = new AdsDataAccess();

        public DataTable GetAds()
        {
            try
            {
                return m_DataAccess.GetAds();
            }
            catch (Exception)
            {

                throw;
            }
        }

        public List<AdsInfo> GetLstAds(DateTime dtNgayBatDau, DateTime dtNgayKetThuc)
        {
            try
            {                
                return m_DataAccess.GetListAds(dtNgayBatDau, dtNgayKetThuc);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public AdsInfo GetAdsById(int aid)
        {
            try
            {
                return m_DataAccess.GetAdsById(aid);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public bool InsertAds(int UserId, AdsInfo ads)
        {
            try
            {
                int aid = m_DataAccess.GetAdsFreeId();
                return m_DataAccess.InsertAds(aid, UserId, ads);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public bool UpdateAds(int aid, int UserId, AdsInfo ads)
        {
            try
            {
                return m_DataAccess.UpdateAds(aid, UserId, ads);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public bool DeleteAds(int aid)
        {
            try
            {
                return m_DataAccess.DeleteAds(aid);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}